package xyz.labmem.base.sys.util

import org.apache.commons.codec.digest.DigestUtils;

class ObjectSerializer {
    fun md5(src: String?): String {
        return DigestUtils.md5Hex(src)
    }

    private val salt = "1a2b3c4d"

    fun inputPassToFormPass(inputPass: String): String {
        val str = "" + salt[0] + salt[2] + inputPass + salt[5] + salt[4]
        println(str)
        return md5(str)
    }

    fun formPassToDBPass(formPass: String, salt: String): String {
        val str = "" + salt[0] + salt[2] + formPass + salt[5] + salt[4]
        return md5(str)
    }

    fun inputPassToDbPass(inputPass: String, saltDB: String): String? {
        val formPass = inputPassToFormPass(inputPass)
        return formPassToDBPass(formPass, saltDB)
    }

}